<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="page-container">
    <div class="text-c">
		
        日期范围：
        <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" name="start_time" value="<{$Think.get.start_time}>" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" name="end_time" value="<{$Think.get.end_time}>" class="input-text Wdate" style="width:120px;">
        <input type="text" name="name" id="name" value="<{$Think.get.name}>" placeholder="产品名称" style="width:250px" class="input-text">
		<input type="text" name="sn" id="sn" value="<{$Think.get.sn}>" placeholder="条形码" style="width:250px" class="input-text">
        <button id="search" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>
			<if condition="I('is_examined') neq 2">
            <a class="btn btn-primary radius" data-title="添加产品" _href="article-add.html" onclick="add()" href="javascript:;"><i class="Hui-iconfont"></i> 添加产品</a>
			</if>
			<!-- <a href="javascript:;" onclick="importexcelAll()" class="btn btn-primary radius"><i class="Hui-iconfont"></i>批量导入</a> -->
			<if condition="I('is_examined') eq 2">
			<a class="dropDown_A btn btn-success" onclick="exportExcel()" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">导出全部</a>
			</if>
        </span>

        <span class="r">共有数据：<strong><{$count}></strong> 条</span>
    </div>
    <div class="mt-20">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
            <div class="dataTables_length" id="DataTables_Table_0_length"><label>
                显示 <select tabindex="<{$Think.get.page_count}>" name="page_count" aria-controls="DataTables_Table_0" class="select">
                <option value="15">15</option><option value="25">25</option><option value="50">50</option>
                <option value="100">100</option></select> 条</label></div>
            <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
            <thead>
            <tr class="text-c" role="row">
                <th width="25" rowspan="1" colspan="1"><input type="checkbox" name="" value=""></th>
                <th width="60" class="sorting_desc" tabindex="id" aria-controls="DataTables_Table_0">ID</th>
                <th class="sorting" tabindex="name" rowspan="1" colspan="1" aria-label="标题: 升序排列" style="width: 120px;">名称</th>
                <!-- <th width="80" class="sorting" tabindex="category">分类</th> -->
                <th width="100">账册编码</th>
                <!-- <th width="60">第一单位(销售单位)</th> -->
				<th width="60">销售单位</th>
				<!-- <th width="75">第一单位规格(规格)</th> -->
                <th width="75">规格</th>
				<!-- <th width="75">第一单位价格(申报单价)</th> -->
				<th width="75">申报单价</th>
				<th width="75">销售单价</th>
                <!-- <th width="60">第二单位</th> -->
                <!-- <th width="80">第二单位数量</th> -->
                <!-- <th width="75">第二单位规格</th> -->
                <!-- <th width="80" class="sorting" tabindex="hs_code">HSCODE</th> -->
                <th width="80" class="sorting" tabindex="goods_no">商品编码</th>
                <th width="60">条形码</th>
                <th width="60">产销国</th>
                <!-- <th width="60">规格</th> -->
                <th width="60">币制</th>
				<th width="60">净重</th>
				<th width="60">毛重</th>
				<th width="60">关税率</th>
				<th width="60">增值税率</th>
				<th width="60">消费税率</th>
				<th width="60">折扣率</th>
				<!-- <th width="60">商品类型</th> -->
                <th width="100">添加时间</th>
                <th width="60">状态</th>
				<?php   //if(!$owner_status){  ?>
				<th width="100"><if condition="$owner_status eq 0">操作<if></th>
				<?php 	//}  ?>
				
            </tr>
            </thead>
            <tbody>
            <foreach name="list" item="data">
            <tr class="text-c odd" role="row">
                <td><input type="checkbox" value="<{$data.id}>" name=""></td>
                <td class="sorting_1"><{$data.id}></td>
                <td class="text-l"><span style="cursor:pointer" class="text-primary"><{$data.name}></span></td>
                <!-- <td><{$data.category}></td> -->
                <td><{$data.zccode}></td>
                <td class="td-status"><{$data.unit}></td>
                <!-- <td><{$data.count}></td> -->
                <td><{$data.standard}></td>
				<td><{$data.price}></td>
				<td><{$data.sell_price}></td>
                <!-- <td class="td-status"><{$data.unit_t}></td> -->
                <!-- <td><{$data.count_t}></td> -->
                <!-- <td> -->
				<!-- <if condition="$data.unit_t_goods_spec neq 'NaN'"> -->
					<!-- <{$data.unit_t_goods_spec}> -->
				<!-- </if> -->
				<!-- </td> -->
                <!-- <td class="td-status"><{$data.hs_code}></td> -->
                <td class="td-status"><span class="label label-success radius"><{$data.goods_no}></span></td>
                <td><{$data.sn}></td>
                <td><{$data.country}></td>
                <!-- <td><{$data.standard}></td> -->
                <td><{$data.currency}></td>
				<td><{$data.net_weight}></td>
				<td><{$data.gross_weight}></td>
				<td><{$data.tariff_rate}></td>
				<td><{$data.increment_rate}></td>
				<td><{$data.consumption_rate}></td>
				<td><{$data.discount_rate}></td>
				<!-- <td> -->
				<!-- <if condition="$data.goods_cate eq 1"> -->
					<!-- 一般商品 -->
				<!-- </if> -->
				<!-- <if condition="$data.goods_cate eq 2"> -->
					<!-- 原料 -->
				<!-- </if> -->
				<!-- <if condition="$data.goods_cate eq 3"> -->
					<!-- 辅料 -->
				<!-- </if> -->
				<!-- </td> -->
                <td><{$data.created_at|substr=0,-3}></td>
                <td>
					<eq name="data.examined" value="0">
						未推送
                    </eq>
					<eq name="data.examined" value="1">
						等待审核
                    </eq>
                    <eq name="data.examined" value="2">
						已审核
                    </eq>
                    <eq name="data.examined" value="3">
                        审核未通过
                    </eq>
                </td>
				<?php   //if(!$owner_status){  ?>
					<td class="f-14 td-manage">
						<a style="text-decoration:none" class="ml-5" onclick="edit('<{$data.id}>')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a>
						<a style="text-decoration:none" class="ml-5" onclick="del('<{$data.id}>','<{$data.examined}>')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>
						<eq name="data.examined" value="0">
							<a style="text-decoration:none" class="ml-5" onclick="pushs('<{$data.id}>')" href="javascript:;" title="推送"><i class="Hui-iconfont Hui-iconfont-arrow1-top"></i>推送</a>
						</eq>
					</td>
				<?php //}  ?>
            </tr>
            </foreach>
            </tbody>
        </table>
            <div class="page">
                <{$page}>
            </div>
    </div>
</div>
<include file="Public/footer" />
<include file="Public/footer_js" />
<script>
	function importexcelAll(){
            var index=layer.open({
                type: 2,
                title: '导入数据',
                shadeClose: true,
                shade: 0.5,
                area: ['1000px', '150px'],
                content: '__MODULE__/import/importProduct/'+Math.random() //iframe的url
            });
        }
    function add(){
	<?php if(!$owner_status){  ?>
		add_url='__MODULE__/Product/add';
	<?php }else{	?>
		add_url='__MODULE__/Product/add_two';
	<?php } ?>
        var index=layer.open({
            type: 2,
            title: '产品信息添加',
            shadeClose: true,
            shade: 0.5,
            offset:['20px'],
            area: ['520px', '605px'],
            content: add_url //iframe的url
        });
    }
    function edit(id){
	<?php if(!$owner_status){  ?>
		edit_url='__MODULE__/Product/edit/id/'+id+"/"+Math.random();
	<?php }else{	?>
		edit_url='__MODULE__/Product/edit_two/id/'+id+"/"+Math.random();
	<?php } ?>
        var index=layer.open({
            type: 2,
            title: '产品信息修改',
            shadeClose: true,
            shade: 0.5,
            offset:['20px'],
            area: ['520px', '835px'],
            content:  edit_url//iframe的url
        });
    }
    function delAll(){
        var all_ipt=$("#DataTables_Table_0_wrapper input[type=checkbox]:checked");
        var group_id='';
        for(var i=0;i<all_ipt.length;i++){
            if(all_ipt.eq(i).val()!==''){
                group_id+='@'+all_ipt.eq(i).val();
            }
        }
        if(group_id.substring(1)==''){
            layer.msg('请勾选要删除的信息');
            return false;
        }
        del(group_id.substring(1));
    }
    function del(id,examined){
		if(examined==2){
			layer.alert("已审核通过不能删除！");
		}else{
			layer.confirm("删除数据后不能恢复，请谨慎删除",function(){
				$.get('__MODULE__/Product/del',{
					id:id,
				},function (msg){
					layer.msg(msg.data);
					if(msg.flag==1){
						setTimeout(function (){
							location.reload();
						},800);
					}
				},'json');
			});
		}
    }
    function pushs(id){
        var index=layer.open({
            type: 1,
            title: '推送仓库选择',
            shadeClose: true,
            shade: 0.5,
            offset:['100px'],
            area: ['320px', '180px'],
            content: "<div id='warehouse' style='padding: 12px;'></div>",
            btn:['确定','取消'],
            success:function (){
                $.get('__MODULE__/Product/getWarehouse',function (msg){
                    if(msg.flag==0){
                        layer.msg('没有仓库信息');
                    }else{
                        var data=msg.data;
                        for(var m in data){
                            $("#warehouse").append("<label><input type='radio' name='wares' value='"+m+"' /> "+data[m]+"</label>");
                        }
                    }
                },'json');
            },
            yes:function (){
                $.get('__MODULE__/Product/push',{
                    id:id,
                    warehouse_id:$("#warehouse input:checked").val(),
                },function (msg){
                    layer.msg(msg.data);
                    if(msg.flag==1){
                        setTimeout(function (){
                            location.reload();
                        },800);
                    }
                },'json');
            }
        });
    }
    $("select[name=page_count]").on('change',function (){
        search();
    });
    $("#search").on('click',function (){
        search();
    });
    function search(_this){
        var page_count=$("select[name=page_count]").val();
        var start_time=$("input[name=start_time]").val();
        var end_time=$("input[name=end_time]").val();
        var name=$("input[name=name]").val();
		var sn=$("input[name=sn]").val();
        var category=$("select[name=category]").val();
        var sort,dec;
        if(_this){
            if(_this.attr('class')=='sorting_desc'){
                sort=_this.attr('tabindex');
                dec='asc';
            }
            if(_this.attr('class')=='sorting_asc'){
                sort=_this.attr('tabindex');
                dec='desc';
            }
            if(_this.attr('class')=='sorting'){
                sort=_this.attr('tabindex');
                dec='asc';
            }
        }else{
            sort='';
            dec='';
        }
		is_examined="<{:I('is_examined')}>";
		if(is_examined==2){
			location.href="__ACTION__?sn="+sn+"&name="+name+"&category="+category+"&page_count="+page_count+"&start_time="+start_time+"&end_time="+end_time+"&sort="+sort+"&dec="+dec+"&is_examined="+is_examined;
		}else{
			location.href="__ACTION__?sn="+sn+"&name="+name+"&category="+category+"&page_count="+page_count+"&start_time="+start_time+"&end_time="+end_time+"&sort="+sort+"&dec="+dec;
		}
    }
	function exportExcel(){
		var url="<{:U('index',array('excel'=>1))}>";
		window.location.href=url;
	}
    (function(){
        if($("select[name=page_count]").attr('tabindex')==''){
            var  page=15;
        }else{
            var  page=$("select[name=page_count]").attr('tabindex');
        }
        $("select[name=page_count]").prop('value',page);
        $(".sorting,.sorting_desc,.sorting_asc").click(function (){
            search($(this));
        });
        for(var i=0;i<$(".sorting,.sorting_desc,.sorting_asc").length;i++){
            if('<{$Think.get.sort}>'!=''){
                if($(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('tabindex')=='<{$Think.get.sort}>'){
                    $(".sorting,.sorting_desc,.sorting_asc").attr('class','sorting');
                    $(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('class','sorting_<{$Think.get.dec}>');
                }
            }
        }
    })();
</script>
</body>
</html>